package com.lgt_enterprise_android.view

import android.os.Bundle
import com.lgt_enterprise_android.R
import com.lgt_enterprise_android.base.BaseActivity
import com.lgt_enterprise_android.utils.HttpManagerKt
import kotlinx.android.synthetic.main.activity_kotlin_test.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

class KotlinTestActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_kotlin_test)

        adsf.text = "ppppp";


        var a: IntArray = intArrayOf(1, 2)


        adsf.setOnClickListener {


            GlobalScope.launch(Dispatchers.Main) {
                val d = HttpManagerKt.login(mContext, "18888888881", "123456", "2", "2");
                log("11111=" + d?.toJSONString())
            }


//            var deferred = GlobalScope.async {
//                var str = "";
//                val okHttpClient = OkHttpClient()"
//                val request = Request.Builder().url("http://lgt-test.ds78.com.cn/api/login?phone_num=18888888881&sms_code=123456&app_type=2&account_type=2").build()
//                val response = okHttpClient.newCall(request).execute()
//                response.run {
//                    body?.let {
//                        val ins = it.string()
//                        str = ins
//                    }
//                }
//                str;
//            }
//
//            runBlocking {
//                println("123="+deferred.await())
//                adsf.text =deferred.await();
//            }


        }

        //http://lgt-test.ds78.com.cn/api/login?phone_num=18888888881&sms_code=123456&app_type=2&account_type=2


    }
}



